﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace GeekShop
{
    public class MenuGroup : MenuItem
    {
        #region Fields
        private List<MenuItem> items = new List<MenuItem>();
        #endregion

        #region Properties
        public List<MenuItem> Items
        {
            get { return items; }
            set { items = value; }
        }
        #endregion

        #region Constructors
        public MenuGroup()
        {
            this.MenuItem = new ToolStripMenuItem() { Visible = true };
            this.ToolItem = new ToolStripSplitButton() { Visible = true };
            this.ToolItem.Click += new EventHandler(this.toolItem_Click);
        }
        #endregion

        #region Public Methods
        public void Add(MenuItem menuItem)
        {
            this.items.Add(menuItem);
            ((ToolStripMenuItem)this.MenuItem).DropDownItems.Add(menuItem.MenuItem);
            ((ToolStripSplitButton)this.ToolItem).DropDownItems.Add(menuItem.ToolItem);
        }
        #endregion

        #region Event Methods
        void toolItem_Click(object sender, EventArgs e)
        {
            ((ToolStripSplitButton)this.ToolItem).ShowDropDown();
        }
        #endregion
    }
}
